/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.felix.httplite.servlet;

import java.util.Dictionary;
import java.util.Enumeration;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;

/**
 * ServletConfig implementation.
 *
 */
public class ServletConfigImpl implements ServletConfig
{
    private final String m_alias;
    private final Dictionary m_initparams;
    private final ServletContext m_servletContext;

    /**
     * @param alias Alias
     * @param initparams Dictionary
     * @param servletContext ServletContext
     */
    public ServletConfigImpl(String alias, Dictionary initparams, ServletContext servletContext)
    {
        this.m_alias = alias;
        this.m_initparams = initparams;
        this.m_servletContext = servletContext;
    }

    /* (non-Javadoc)
     * @see javax.servlet.ServletConfig#getServletName()
     */
    public String getServletName()
    {
        return m_alias;
    }

    /* (non-Javadoc)
     * @see javax.servlet.ServletConfig#getServletContext()
     */
    public ServletContext getServletContext()
    {
        return m_servletContext;
    }

    /* (non-Javadoc)
     * @see javax.servlet.ServletConfig#getInitParameterNames()
     */
    public Enumeration getInitParameterNames()
    {
        if (m_initparams != null)
        {
            return m_initparams.keys();
        }

        return HttpConstants.EMPTY_ENUMERATION;
    }

    /* (non-Javadoc)
     * @see javax.servlet.ServletConfig#getInitParameter(java.lang.String)
     */
    public String getInitParameter(String arg0)
    {
        if (m_initparams != null)
        {
            return m_initparams.get(arg0).toString();
        }

        return null;
    }

}
